/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package systole.view.tabs.results;

import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import systole.domain.analysis.results.ParametersKind;
import systole.domain.analysis.results.averages.AverageByDecade;

/**
 *
 * @author jmj
 */
public class IndexesTableModel extends DefaultTableModel {

    private AverageByDecade average;

    public IndexesTableModel(AverageByDecade average) {
        super();
        this.addColumn("Índice");
        this.addColumn("Observación");
        this.addColumn("Promedio");
        this.average = average;
        this.initTable();
    }

    private void initTable() {
        this.addRow(ParametersKind.AOD, ((average != null) ? average.getAverageAOD().getValueAsString() : ""));
        this.addRow(ParametersKind.IAR, ((average != null) ? average.getAverageIAR().getValueAsString() : ""));
        this.addRow(ParametersKind.AOS, ((average != null) ? average.getAverageAOS().getValueAsString() : ""));        
    }

    private void addRow(String indexDescription, String valor) {
        String magnitude = (indexDescription.equals( ParametersKind.AOS)) ? "ms":"%";
        Vector rowData = new Vector();
        rowData.add(indexDescription);
        rowData.add(null);
        rowData.add("promedio disponible (" + valor + "["+ magnitude +"])");
        this.addRow(rowData);
    }

    @Override
    public boolean isCellEditable(int row, int column) {
        return (column == 1);
    }



}
